<?

require_once("include/bittorrent.php");
dbconn();

//Start residence detection script

$detectres = 0;
$ip = $_SERVER['REMOTE_ADDR'];
$dns = @gethostbyaddr($ip);
$resnetmin = "128.189.128.0";
$resnetmax = "128.189.191.255";
$minip1 = "128.189.164.0";
$maxip1 = "128.189.165.255";
$minip2 = "128.189.176.0";
$maxip2 = "128.189.179.0";
$minip3 = "128.189.187.0";
$maxip3 = "128.189.191.255";


if ((ip2long($ip) > ip2long($resnetmin)) &&  (ip2long($ip) < ip2long($resnetmax)))
{
if (preg_match ("/srtp/i", $dns))
$detectres = 1;
else if (preg_match("/srrt/i", $dns))
$detectres = 3;
else if (preg_match("/srge/i", $dns) || preg_match ("/srga/i", $dns) || preg_match ("/srgs/i", $dns) || preg_match ("/srgn/i", $dns) || ((ip2long($ip) > ip2long($minip1)) &&  (ip2long($ip) < ip2long($maxip1))))
$detectres = 4;
else if (preg_match("/srfc/i", $dns))
$detectres = 5;
else if (preg_match("/srmd/i", $dns) || ((ip2long($ip) > ip2long($minip2)) &&  (ip2long($ip) < ip2long($maxip2))))
$detectres = 7;
else if ((ip2long($ip) > ip2long($minip3)) &&  (ip2long($ip) < ip2long($maxip3)))
$detectres = 6;
else
$detectres = 2;
}

//End residence detection script

$res = query("SELECT COUNT(*) FROM users") or sqlerr(__FILE__, __LINE__);
$arr = mysql_fetch_row($res);
if ($arr[0] >= $maxusers)
	alert("Sorry", "The current user account limit (" . number_format($maxusers) . ") has been reached. Inactive accounts are pruned all the time, please check back again later...");

$residences = "<option value=0>None</option>\n";
$ct_r = query("SELECT id,name FROM residences ORDER BY id") or die;
while ($ct_a = mysql_fetch_array($ct_r))
  $residences .= "<option value=$ct_a[id]" . ($detectres == $ct_a['id'] ? " selected" : "") . ">$ct_a[name]</option>\n";

stdhead("Signup");

?>
Note: You need cookies enabled to sign up or log in.
<p>
<form method="post" action="takesignup.php">
<table border="1" cellspacing=0 cellpadding="10">
<tr valign=top><td align="right" class="heading">Desired username:</td><td align=left><input type="text" size="40" name="wantusername" />
<table width=250 border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><font class=small>Use your Rezhub name if you have one!</td></tr>
</font></td></tr></table>
</td></tr>
<tr><td align="right" class="heading">Pick a password:</td><td align=left><input type="password" size="40" name="wantpassword" /></td></tr>
<tr><td align="right" class="heading">Enter password again:</td><td align=left><input type="password" size="40" name="passagain" /></td></tr>
<tr valign=top><td align="right" class="heading">Email address:</td><td align=left><input type="text" size="40" name="email" />
<table width=250 border=0 cellspacing=0 cellpadding=0><tr><td class=embedded><font class=small>The email address must be valid.
You will receive a confirmation email which you need to respond to. The email address won't be publicly shown anywhere.</td></tr>
</font></td></tr></table>
</td></tr>
<? tr("Gender",
"\n<input type=radio name=gender value=Male checked>Male
<input type=radio name=gender value=Female>Female\n"
,1);
tr("Residence", "<select name=residence>\n$residences\n</select>",1);
?>
<tr><td align="right" class="heading"></td><td align=left><input type=checkbox name=verify value=yes> I have read the site <a href=rules.php>rules</a> and <a href=faq.php>faq</a>.</td></tr>
<tr><td colspan="2" align="center"><input type=submit value="Sign up! (PRESS ONLY ONCE)" style='height: 25px'></td></tr>
</table>
</form>
<?

stdfoot();

?>